import { Injectable } from '@angular/core';
import { ActiveToast, IndividualConfig, ToastrService } from 'ngx-toastr';

/* 替代 abp.notify.js，sweetAlert2的toast弹窗一次只能打开一个，
 * toast.js的版本太老就不引入了，改用ngx-toastr
 * 
 * */

@Injectable()
export class AppNotifyService{

    constructor(private toastr: ToastrService) {

    }

    info(message: string, title?: string, override?: Partial<IndividualConfig>): ActiveToast<any> {
        return this.toastr.info(message, title, override);
    }

    success(message: string, title?: string, override?: Partial<IndividualConfig>): ActiveToast<any>  {
        return this.toastr.success(message, title, override);
    }
    warn(message: string, title?: string, override?: Partial<IndividualConfig>): ActiveToast<any>  {
        return this.toastr.warning(message, title, override);
    }
    error(message: string, title?: string, override?: Partial<IndividualConfig>): ActiveToast<any>  {
        return this.toastr.error(message, title, override);
    }
}
